<?php if( count($this->navigation) > 0 ): ?>
<div class="headline">
    <h2><?php echo $this->translate('Questions');?></h2>
    <div class="tabs">
      <?php
        // Render the menu
        echo $this->navigation()
          ->menu()
          ->setContainer($this->navigation)
          ->render();
      ?>  
    </div>
</div>    
<?php endif; ?>


<?php if (isset($this->do) && $this->do == 'create'): ?>
<style type="text/css">
#compose-menu {display: block;}
#compose-submit, #activity_body, .compose-content {display: none !important;}
#compose-menu {margin-top: 0px;}
.questions_paginator_container {padding: 10px;}
</style>
    <form method="post" action="<?php echo $this->url(array('module' => 'activity', 'controller' => 'index', 'action' => 'post'), 'default', true) ?>" enctype="application/x-www-form-urlencoded" style="display: none;" id="activity-form">
          <textarea id="activity_body" cols="1" rows="1" name="body"></textarea>
          <input type="hidden" name="return_url" value="<?php echo $this->url() ?>" />
          <div id="compose-menu" class="compose-menu">
            <button id="compose-submit" type="submit"><?php echo $this->translate("Share") ?></button>
          </div>
    </form>
    <script type="text/javascript">    
    window.addEvent('domready', function(){
        composeInstance.getPlugin('poll').activate();
    });
    </script>

    <?php
      $this->headScript()
        ->appendFile($this->baseUrl() . '/externals/mdetect/mdetect' . ( APPLICATION_ENV != 'development' ? '.min' : '' ) . '.js')
        ->appendFile($this->baseUrl() . '/application/modules/Core/externals/scripts/composer.js')
        ->appendFile($this->baseUrl() . '/application/modules/Poll/externals/scripts/composer.js');
    ?>

    <script type="text/javascript">
    composeInstance = new Composer('activity_body', {
        menuElement : 'compose-menu',
        baseHref : '<?php echo $this->baseUrl() ?>',
        lang : {
          'Post Something...' : '<?php echo $this->string()->escapeJavascript($this->translate('Post Something...')) ?>'
        }
    }); 
    </script> 
    <script type="text/javascript">
      en4.core.runonce.add(function() {
        var type = 'wall';
        if (composeInstance.options.type) type = composeInstance.options.type;
        composeInstance.addPlugin(new Composer.Plugin.Poll({
          title : '<?php echo $this->string()->escapeJavascript($this->translate('Ask Question')) ?>',
          lang : {
            'Ask Question' : '<?php echo $this->string()->escapeJavascript($this->translate('Ask Question')) ?>',
            'Ask something...' : '<?php echo $this->string()->escapeJavascript($this->translate('Ask something...')) ?>',
            'Add an option...' : '<?php echo $this->string()->escapeJavascript($this->translate('Add an option...')) ?>',
            'Allow anyone to add options' : '<?php echo $this->string()->escapeJavascript($this->translate('Allow anyone to add options')) ?>',
            'Add Poll' : '<?php echo $this->string()->escapeJavascript($this->translate('Add Poll')) ?>',
            'Share' : '<?php echo $this->string()->escapeJavascript($this->translate('Share')) ?>',
            'Public' : '<?php echo $this->string()->escapeJavascript($this->translate('Public')) ?>',
            'Friends' : '<?php echo $this->string()->escapeJavascript($this->translate('Friends')) ?>'
          },
          out_of_feed : true
        }));
      });
    </script>
<?php endif; ?>
   
<?php foreach ($this->paginator as $question): ?>
    <div class="poll_title">
        <?php $owner = Engine_Api::_()->user()->getUser($question->user_id);?>
        <div class="owner_avatar"><?php echo $this->htmlLink($owner->getHref(), $this->UPhoto($owner, 'thumb.icon'));?></div>
        <div class="questions_question_content">
            <?php echo $this->translate('%s asked %s', $this->htmlLink($owner->getHref(), $owner->getTitle()), $this->htmlLink($question->getHref(), $question->getTitle()));?>
            <div class="poll_options_container">
            <?php echo $this->partial('_displayPoll.tpl', 'poll', array('item' => $question, 'options' => $question->getOptions(), 'show_title' => true));?>
            </div>
        </div>
    </div>        
<?php endforeach; ?>
<?php echo $this->paginationControl($this->paginator);?>